<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>搜索结果</title>
    <link href="res/static/css/main.css" rel="stylesheet" type="text/css">
    <link href="res/layui/css/layui.css" rel="stylesheet" type="text/css">
    <script src="res/layui/layui.js" type="text/javascript"></script>
    <script src="res/static/js/util/jquery-3.3.1.min.js" type="text/javascript"></script>
    <script src="res/static/js/util/jquery.cookie.js" type="text/javascript"></script>
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
          name="viewport">
    <meta content="IE=Edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>

<div class="site-nav-bg">
    <div class="site-nav w1200">
        <p class="sn-back-home">
            <i class="layui-icon layui-icon-home"></i>
            <a href="index.html">首页</a>
        </p>
        <div class="sn-quick-menu">
            <div class="login"><a href="login.html" id="loginbtn">登录</a></div>
            <div class="sp-cart"><a href="shopcart.html">购物车</a><span id="cart-num">0</span></div>
        </div>
    </div>
</div>


<div class="header">
    <div class="headerLayout w1200">
        <div class="headerCon">
            <h1 class="mallLogo">
                <a href="index.html" title="极品商城">
                    <img src="res/static/img/logo.png">
                </a>
            </h1>
            <div class="mallSearch">
                <form action="search_list.html" class="layui-form" novalidate>
                    <input autocomplete="off" class="layui-input" id="search" lay-verify="required" name="title"
                           placeholder="请输入需要的商品" required type="text">
                    <button class="layui-btn" lay-filter="formDemo" lay-submit>
                        <i class="layui-icon layui-icon-search"></i>
                    </button>
                    <input name="" type="hidden" value="">
                </form>
            </div>
        </div>
    </div>
</div>


<div class="content content-nav-base commodity-content">
    <div class="main-nav">
        <div class="inner-cont0">
            <div class="inner-cont1 w1200">
            </div>
        </div>
    </div>
    <div class="commod-cont-wrap">
        <div class="commod-cont w1200 layui-clear">
            <div class="right-cont-wrap" style="margin-left: 150px;">
                <div class="right-cont">

                    <div class="cont-list layui-clear" id="list-cont">

                    </div>

                    <!-- 模版引擎导入 -->
                    <script id="demo" type="text/html">
                        {{# layui.each(d.content,function(index,item){}}
                        <div class="item">
                            <div class="img">
                                <a href="details.html?id={{item.id}}"><img src="{{item.item_image_path}}"
                                                                           style="width: 280px;height: 280px;padding: 0px;"></a>
                            </div>
                            <div class="text">
                                <p class="title"></p>
                                <p class="price">
                                <div class="title" style="width: 270px;height: 20px;overflow: hidden;">{{item.title}}
                                </div>
                                <span class="pri">￥{{item.price}}</span>

                                </p>
                            </div>
                        </div>
                        {{# }); }}
                    </script>
                    <div id="demo0" style="text-align: center;"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="footer">
    <div class="ng-promise-box">
        <div class="ng-promise w1200">
            <p class="text">
                <a class="icon1" href="javascript:">7天无理由退换货</a>
                <a class="icon2" href="javascript:">满99元全场免邮</a>
                <a class="icon3" href="javascript:" style="margin-right: 0">100%品质保证</a>
            </p>
        </div>
    </div>
    <div class="mod_help w1200">
        <p>
            <a href="javascript:">关于我们</a>
            <span>|</span>
            <a href="javascript:">帮助中心</a>
            <span>|</span>
            <a href="javascript:">售后服务</a>
            <span>|</span>
            <a href="javascript:">极品资讯</a>
            <span>|</span>
            <a href="javascript:">关于货源</a>
        </p>
        <p class="coty">极品商城版权所有 &copy; 2012-2020</p>
    </div>
</div>
<script type="text/javascript">
    document.getElementById('search').value = decodeURI(window.location.href.split('title=')[1]) === 'undefined' ? decodeURI(window.location.href.split('category=')[1]) : decodeURI(window.location.href.split('title=')[1]);
    layui.config({
        base: 'res/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
    }).use(['mm', 'carousel'], function () {
        var carousel = layui.carousel,
            mm = layui.mm;
        var html = demo.innerHTML;
        var listCont = document.getElementById('list-cont');
        var url = '';
        if (window.location.href.indexOf('title') >= 0) {
            url = 'search?title=' + window.location.href.split('title=')[1];
        } else {
            url = 'searchByCategory?category=' + window.location.href.split('category=')[1];
        }
        mm.request({
            url: url,
            success: function (res) {
                console.log(res);
                listCont.innerHTML = mm.renderHtml(html, res);
            },
            error: function (res) {
                console.log(res);
            }
        })

    });
</script>

<script type="text/javascript">
    $(function () {
        getCartNum();

        // 调用
        var x = getCookie("userTel");
        if (x != null && x !== "") {
            $("#loginbtn").html("个人中心");
            $("#loginbtn").prop("href", "consumer_center.html");
        }


        function getCookie(cname) {
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i].trim();
                if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
            }
            return "";
        }

        function getCartNum() {  //获取购物车中商品数量
            var index = 0;
            for (var i = 0; i < 30; i++) {
                if ($.cookie(i.toString()) == null) {

                } else {
                    index++;
                }
            }
            $("#cart-num").html(index);
        }

    })
</script>

</body>
</html>